
package com.xtsoft.platform.base.database.domain;

/*
*    上海信拓信息技术有限公司  
*    Copyright (C) ShangHai XinTuo Software Inc.
*/

import com.xtsoft.core.entity.GenericEntity;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.hibernate.annotations.GenericGenerator;

import jakarta.persistence.*;

/**
 * DbSql Base Java Bean, base class for the model, mapped directly to database
 * table
 * 
 * Avoid changing this file if not necessary, will be overwritten.
 *
 * 存储输入的SQL脚本
 */
@Entity
@Table(name = "db_sql")
@Data
public class DbSql extends GenericEntity {

	@Id
	@GeneratedValue(generator = "system-uuid")
	@GenericGenerator(name = "system-uuid", strategy = "uuid")
	@Column(name = "dbSqlId", nullable = false, length = 32)
	private String dbSqlId;

	/**
	 * sql名称
	 */
	@Column(name = "sqlName", nullable = false, length = 128)
	private String sqlName;

	/**
	 * 说明
	 */
	@Column(name = "descript", nullable = true, length = 255)
	private String descript;

	/**
	 * sql语句
	 */
	@Column(name = "sqlStat", nullable = false, length = 16384)
	private String sqlStat;

	/**
	 * importedKeys
	 */
	@ManyToOne
	@JoinColumn(name = "dbConnectId")
	private DbConnect dbConnect;

	/**
	 * 默认构造
	 */
	public DbSql() {

	}

	/**
	 * 构造方法，自动测试使用，把除主键外的所有非空字段赋值
	 *
	 * 也可作普通使用 调用该构造方法时，字串参数填或不填均 可，该带参构造方法仅为区别Lombok自动生成的默认构造方 法。
	 * 
	 * 应用程序可根据需要修改该构造方法中的非空属性赋值。
	 **/
	public DbSql(String forAutoTest) {

		this.sqlName = "New string";

		this.sqlStat = "New string";

	}

	/**
	 * @see Object#toString()
	 */
	public String toString() {
		return new ToStringBuilder(this).append("dbSqlId", this.dbSqlId).append("sqlName", this.sqlName)
				.append("descript", this.descript).append("sqlStat", this.sqlStat).append("DbConnect", this.dbConnect)
				.toString();
	}

	/**
	 * 以实体类主键生成HASHCODE
	 */
	@Override
	public int hashCode() {
		return this.dbSqlId.hashCode();
	}

	/**
	 * 以实体类主键比较对象是否相等
	 */
	@Override
	public boolean equals(Object obj) {
		if (obj instanceof DbSql) {
			return this.dbSqlId.equals(((DbSql) obj).getDbSqlId());
		}
		return false;
	}

}
